package br.com.project;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.Toast;

public class GridMenuActivity extends TemplateActivity {
	
	private static int SIMULATION_ONLINE = 0;
	private static int SIMULATION_OFFLINE = 1;
	private static int ALL_INFORMATION = 2;
	private static int MY_INFORMATION = 3;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.gridmenu);
		
		GridView g = (GridView) findViewById(R.id.myGrid);
		g.setAdapter(new ImageAdapter(this));
		g.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> parent, View v,
					int position, long id) {
				if(position == SIMULATION_ONLINE){
					openSimulation();
				} else if (position == SIMULATION_OFFLINE){
					openLocalSimulation();
				}  else if(position == ALL_INFORMATION){
					openAllInformation();
				} else if(position == MY_INFORMATION){
					openMyInformation();
				} else {
					Toast.makeText(GridMenuActivity.this, "" + position,
							Toast.LENGTH_SHORT).show();
				}
			}
		});
		
	}
	
	public void openSimulation() {
		Intent myIntent = new Intent(GridMenuActivity.this, SimulationListActivity.class);
        startActivityForResult(myIntent, 0);
    }
	
	public void openLocalSimulation() {
		Intent myIntent = new Intent(GridMenuActivity.this, SimulationListLocalActivity.class);
        startActivityForResult(myIntent, 0);
    }
	
	public void openMyInformation() {
		Intent myIntent = new Intent(GridMenuActivity.this, MyInformationActivity.class);
        startActivityForResult(myIntent, 0);
    }
	
	public void openAllInformation(){
		Toast.makeText(GridMenuActivity.this, "ALL INFORMATION",
				Toast.LENGTH_SHORT).show();
	}
	
}
